package com.starry.core.utils


import com.starry.core.App
import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.starry.core.R


object GlideUtils {

    private val options: RequestOptions = RequestOptions()
        .placeholder(R.drawable.pic_empty) //占位图
        .error(R.drawable.pic_empty) //错误图
        .skipMemoryCache(true) //禁用掉Glide的内存缓存功能

    fun loadImage(context: Context?, url: String?, iv: ImageView?) {
        Glide.with(context!!).load(url).apply(options).into(iv!!)
    }

    fun loadCircleImage(context: Context? = App.mContext, url: String?, iv: ImageView?) {
        val requestOptions = options.centerCrop().circleCrop()
        Glide.with(context!!).load(url).apply(requestOptions).into(iv!!)
    }

}